/************************************************************************
 * SMLib - State Model Library
 * Copyright (C) 2012-2013 Ali Khalili (khalili_DOT_ir_@SIGN_gmail_DOT_com)
 * **********************************************************************
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License (LGPL) published 
 * by the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version. This program is distributed without any
 * warranty. See the GNU Lesser General Public License for more details. 
 * ***********************************************************************
 * File         :     
 * Description  :     
 * Change log   :     
 * To Do        :
 ************************************************************************/
using System;

namespace SMLib.Automata.Base
{
	/// <summary>
	/// Each step of a trace in IA
	/// </summary>
	public class Step
	{
		bool isInput;
		ISymbol symb;
		
		/// <summary>
		/// Initializes a new instance of the <see cref="SMLib.Automata.Base.Step"/> class.
		/// </summary>
		/// <param name='symb'>
		/// The symbol
		/// </param>
		/// <param name='isInput'>
		/// Whether it is input (true) or output (false)
		/// </param>
		public Step (ISymbol symb, bool isInput)
		{
			if(symb==null)
				throw new Exception("The symbol cannot be null!");
			this.symb=symb;
			this.isInput=isInput;
		}
		
		/// <summary>
		/// Gets the symbol.
		/// </summary>
		/// <value>
		/// The symbol.
		/// </value>
		public ISymbol Symbol
		{
			get
			{
				return symb;
			}
		}
		
		/// <summary>
		/// Gets a value indicating whether this instance is input.
		/// </summary>
		/// <value>
		/// <c>true</c> if this instance is input; otherwise, <c>false</c>.
		/// </value>
		public bool IsInput
		{
			get
			{
				return isInput;
			}
		}
		
		/// <summary>
		/// Gets a value indicating whether this instance is output.
		/// </summary>
		/// <value>
		/// <c>true</c> if this instance is output; otherwise, <c>false</c>.
		/// </value>
		public bool IsOutput
		{
			get
			{
				return ! isInput;
			}
		}
		
		/// <summary>
		/// Changes the symbol.
		/// </summary>
		/// <param name='symb'>
		/// The new symbol to be replaced
		/// </param>
		public void ChangeSymbol(ISymbol symb)
		{
			this.symb=symb;			
		}
		
		/// <summary>
		/// Changes the kind
		/// </summary>
		/// <param name='isInput'>
		/// Is input or output?
		/// </param>
		public void ChangeKind(bool isInput)
		{
			this.isInput=isInput;
		}
		
		public override string ToString ()
		{				
			return (isInput?"?":"!")+symb.ToString();
		}
	}
}

